/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package domain.controllers.validators;

import domain.commands.TareaComando;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 *
 * @author jorge
 */

public class EtiquetarValidator implements Validator {

	public boolean supports(Class clazz) {
		
		return TareaComando.class.isAssignableFrom(clazz);
	}
	public void validate(Object comando, Errors errors) {
            
            TareaComando tc = (TareaComando)comando;
            String s = tc.getEtiqueta();
           
             if(s.contains(",")){
                 errors.rejectValue("etiqueta", "etiqueta.correcto","Por favor no introduzca comas entre etiquetas, sólo un espacio en blanco");
             }
        }
         

}